@extends("layouts.backend.webadmin")


<link rel="stylesheet" href="{{env('APP_ROOT')}}/assets/layui/css/layui.css">
<script src="{{env('APP_ROOT')}}/assets/layui/layui.js"></script>

@section('content')

    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-body">

                            <form method="POST"  class="layui-form" lay-filter="boardFilter" action="{{ URL::route('admin.flaw.checkedForm') }}">

                                <div class="form-group">
                                    <label for="vulsCategoryId">漏洞编号</label><br>
                                    @foreach ($vuls as $lists)
                                        <blockquote id="vulsCategoryId" class="layui-elem-quote layui-quote-nm">
                                            {{$lists->vuls_number}}
                                        </blockquote>
                                    @endforeach
                                </div>
                                @needsroles([2,3])
                                <div class="form-group">
                                    <label for="vulsCategoryId">标题</label><br>
                                    @foreach ($vuls as $lists)
                                        <blockquote id="vulsCategoryId" class="layui-elem-quote layui-quote-nm">
                                            {{$lists->title}}
                                        </blockquote>
                                    @endforeach
                                </div>
                                @endauth
                                <div class="form-group">
                                    <label for="vulsCategoryId">副标题</label><br>
                                    @foreach ($vuls as $lists)
                                        <blockquote class="layui-elem-quote layui-quote-nm" id="vulsCategoryId">
                                            {{$lists->description}}
                                        </blockquote>
                                    @endforeach
                                </div>
                                <div class="form-group">
                                    <label for="vulsCategoryId">漏洞URL</label><br>
                                    @foreach ($vuls as $lists)
                                        <blockquote id="vulsCategoryId" class="layui-elem-quote layui-quote-nm">
                                            {{$lists->form_url}}
                                        </blockquote>
                                    @endforeach
                                </div>
                                <div class="form-group">
                                    <label for="vulsCategoryId">URL参数</label><br>
                                    @foreach ($vuls as $lists)
                                        <blockquote id="vulsCategoryId" class="layui-elem-quote layui-quote-nm">
                                            {{$lists->url_parms}}
                                        </blockquote>
                                    @endforeach
                                </div>
                                <div class="form-group">
                                    <label for="vulsCategoryId">Payload</label><br>
                                    @foreach ($vuls as $lists)
                                        <blockquote id="vulsCategoryId" class="layui-elem-quote layui-quote-nm">
                                            {{$lists->payload}}
                                        </blockquote>
                                    @endforeach
                                </div>
                                <div class="form-group">
                                    <label for="vulsCategoryId">漏洞详情</label><br>
                                    <blockquote class="layui-elem-quote layui-quote-nm" id="vulsCategoryId">
                                        {!!$vuls[0]->content  !!}
                                    </blockquote>
                                </div>
                                <div class="form-group">
                                    <label for="vulsCategoryId">参考资料</label><br>
                                    @foreach($vuls[0]->ref as $ref)
                                        <div class="col-md-12">
                                            <a style="padding-left:15px;" target="_blank" href="{{route('knowledge.showpage',['id'=>$ref->id])}}">{{mb_substr($ref->title,0,50)}}</a>
                                        </div>
                                    @endforeach
                                </div>

                                <div class="row">
                                    <div class="col-md-4">
                                        <label for="level">漏洞评级</label><br>
                                        <select style="color: red;" class="form-control" lay-filter="level" id="level" name="level">
                                            <option value="">--请选择评级--</option>
                                            @if($level)
                                                @foreach ($level as $lists)
                                                    <option @if($lists->id==$vuls[0]->level_id)  selected  @endif
                                                    value="{{$lists->id}}">{{$lists->name}}</option>
                                                @endforeach
                                            @endif
                                        </select>
                                    </div>
                                    <div class="col-md-4">
                                        <label for="credit">积分 </label>
                                        <select class="form-control" id="credit" lay-filter="credit"  name="credit">
                                            <option value="">--请选择积分--</option>
                                            @if(!empty($vuls[0]->max_integ))
                                                @for($i=$vuls[0]->min_integ ; $i<=$vuls[0]->max_integ; $i++)
                                                    <option @if($vuls[0]->credit==$i)  selected  @endif value="{{$i}}">{{$i}}</option>
                                                @endfor
                                            @else
                                                <option value="{{$vuls[0]->max_integ}}">{{$vuls[0]->max_integ}}</option>
                                            @endif
                                        </select>
                                    </div>
                                    <div class="col-md-4">
                                        <label for="reward">金币 </label>
                                        <select class="form-control" id="reward" lay-filter="reward"  name="reward">
                                            <option value="">--请选择金币--</option>
                                            @if(!empty($vuls[0]->max_reward))
                                                @for($i=$vuls[0]->min_reward ; $i<=$vuls[0]->max_reward; $i++)
                                                    <option @if($vuls[0]->reward==$i)  selected  @endif value="{{$i}}">{{$i}}</option>
                                                @endfor
                                            @else
                                                <option value="{{$vuls[0]->max_reward}}">{{$vuls[0]->max_reward}}</option>
                                            @endif
                                        </select>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label>描述</label>
                                    <textarea class="form-control" maxlength="255" required rows="3" placeholder="相关描述..."
                                              name="description"></textarea>
                                </div>
                                <div class="form-group">
                                    {{csrf_field()}}
                                    <input type="hidden" name="id" value="{{$id}}">
                                    <button type="submit" name="Reconfirmation" value="Reconfirmation"
                                            class="layui-btn layui-btn-primary">提交
                                    </button>
                                </div>
                                <div class="form-group">
                                    <label for="vulsCategoryId">修复过程</label>
                                    <blockquote class="layui-elem-quote layui-quote-nm">
                                        <ul class="layui-timeline">
                                            @foreach($record as $records)
                                                <li class="layui-timeline-item">
                                                    <i class="layui-icon layui-timeline-axis">&#xe63f;</i>
                                                    <div class="layui-timeline-content layui-text">
                                                        <h3 class="layui-timeline-title">
                                                            @if($records->updated_at)
                                                                {{$records->updated_at}}
                                                            @else
                                                                {{$records->created_at}}
                                                            @endif
                                                        </h3>
                                                        <ul>
                                                            @if($records->vuls_status)
                                                                <li>
                                                                    状态：{{$status[$records->vuls_status]['name']}}
                                                                </li>
                                                            @endif
                                                                @if($records->creatname)
                                                                    <li>
                                                                        创建者：{{$records->creatname}}({{$records->creal_name}})({{$records->phone}})
                                                                    </li>
                                                                @endif


                                                                @if($records->updatename)
                                                                    <li>
                                                                        更新者：{{$records->updatename}}({{$records->ureal_name}})({{$records->phone}})
                                                                    </li>
                                                                @endif
                                                                @if($records->reward)
                                                                    <li>
                                                                        当前金币：{{$records->reward}}
                                                                    </li>
                                                                @endif
                                                                @if($records->credit)
                                                                    <li>
                                                                        当前积分：{{$records->credit}}
                                                                    </li>
                                                                @endif
                                                            @if($records->content)
                                                                <li>
                                                                    说明：{{$records->content}}
                                                                </li>
                                                            @endif

                                                        </ul>
                                                    </div>
                                                </li>
                                            @endforeach
                                        </ul>
                                    </blockquote>
                                </div>

                            </form>
                        <input type="hidden" id="error" value="@foreach ($errors->all() as $error){{ $error }}@endforeach">
                        @if(count($errors->all()))
                            <script type="text/javascript">
                                var message=$("#error").val();
                                layui.use('layer', function(){
                                    var layer = layui.layer;
                                    layer.open({
                                        title: '错误提示'
                                        ,content: message
                                    });
                                });
                            </script>

                        @endif
                        <input type="hidden" id="errors" value="{{session('flow_error')}}">
                        @if(session('flow_error'))
                            <script type="text/javascript">
                                var message=$("#errors").val();
                                layui.use('layer', function(){
                                    var layer = layui.layer;
                                    layer.open({
                                        title: '错误提示'
                                        ,content: message
                                    });
                                });
                            </script>

                        @endif
                    </div>
                </div>
            </div>
        </div>
    </section>
    <script>
        layui.use('form', function(){
            var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
            form.render();
            form.on('select(level)', function(data){
                var  level=$("#level").val()
                $.ajax({
                    type: 'POST',
                    url: "{{route('vuls.ajax')}}",//发送请求
                    data: {'_token':'{{csrf_token()}}','level':level},
                    dataType : "json",
                    success: function(result) {
                        if(result)
                        {
                            var reward="  <option value=''>--请选择金币--</option>";
                            var credit="  <option value=''>--请选择积分--</option>";
                            for(var i=result[0].min_reward ; i<=result[0].max_reward;i++)
                            {
                                reward+="<option value="+i+">"+i+"</option>"
                            }
                            for(var i=result[0].min_integ ; i<=result[0].max_integ;i++)
                            {
                                credit+="<option value="+i+">"+i+"</option>"
                            }
                            $("#reward").html(reward);
                            $("#credit").html(credit);
                            layui.form.render('select','boardFilter');
                        }
                    }
                });
            });
        });

    </script>
@stop